package com.wongsir.tiny_ioc.step2;

import org.junit.Test;

import com.wongsir.step2.tiny_ioc.BeanDefinition;
import com.wongsir.step2.tiny_ioc.factory.AutowireCapableBeanFactory;
import com.wongsir.step2.tiny_ioc.factory.BeanFactory;

/**
 * step2:抽象化后的BeanFactory测试
 * @author wongsir
 * @date 2018年9月13日
 */
public class BeanFactoryTest2 {
	
	@Test
	public void test() {
		//1、初始化beanFactory
		BeanFactory beanFactory = new AutowireCapableBeanFactory();
		
		//2、注入bean
		BeanDefinition beanDefinition = new BeanDefinition();
		beanDefinition.setBeanClassName("com.wongsir.tiny_ioc.step2.HelloWorldService");
		beanFactory.registerBeanDefinition("helloWorldService", beanDefinition);
		
		//3、获取bean
		HelloWorldService helloWorldService = (HelloWorldService)beanFactory.getBean("helloWorldService");
		helloWorldService.helloworld();
	}
	
}
